
<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>授信额度管理</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 搜索筛选 -->
    <el-form :inline="true" :model="formInline" class="user-search">
      <el-form-item label="搜索：">
        <el-input v-model="formInline.id" placeholder="额度编号"></el-input>
      </el-form-item>
      <el-form-item label="搜索：">
        <el-input v-model="formInline.bname" placeholder="授信机构"></el-input>
      </el-form-item>
      <el-form-item label="搜索：">
        <el-select v-model="formInline.status" placeholder="状态">
          <el-option
            v-for="item in statusOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="search"
          >搜索</el-button
        >
      </el-form-item>
      <div style="float: right; margin-top: -20px">
        <el-card class="box-card" body-style="padding:10px">
          <svg
            t="1655111203869"
            class="icon"
            viewBox="0 0 1024 1024"
            version="1.1"
            xmlns="http://www.w3.org/2000/svg"
            p-id="2175"
            width="48"
            height="48"
            style="float: left; position: relative; top: 20px"
          >
            <path
              d="M512.483467 824.946804c27.883666 0 50.394238-22.577306 50.394238-50.399294l0-100.655009 101.466938 0c28.087912 0 50.665218-22.577306 50.665218-50.532762 0-27.816932-22.577306-50.527706-50.665218-50.527706L562.877705 572.832034l0-50.532762 101.466938 0c28.087912 0 50.665218-22.510572 50.665218-50.466028 0-27.883666-22.577306-50.460972-50.665218-50.460972l-76.269819 0 69.681359-69.819882c19.691569-19.686513 19.691569-51.671283 0-71.495309-19.686513-19.686513-51.738017-19.686513-71.429586 0.07179l-66.855277 66.922011-66.928078-66.922011c-19.686513-19.758303-51.671283-19.758303-71.429586-0.07179-19.753247 19.824026-19.753247 51.808796 0 71.495309l69.748093 69.819882-89.572118 0c-27.817943 0-50.527706 22.577306-50.527706 50.460972 0 27.955455 22.709763 50.466028 50.527706 50.466028l100.59333 0 0 50.532762-100.59333 0c-27.817943 0-50.527706 22.711785-50.527706 50.527706 0 27.955455 22.709763 50.532762 50.527706 50.532762l100.59333 0 0 100.655009C461.950706 802.369497 484.594746 824.946804 512.483467 824.946804L512.483467 824.946804zM512.483467 824.946804M955.837496 294.708215c-1.814961-4.97269-4.101104-9.540932-7.054587-13.642036-0.404448-0.670373-0.809907-1.409502-1.075832-2.081897l-0.537916 0.201213c-8.802814-10.883699-22.305315-17.805829-37.29113-17.805829-26.879623 0-48.717801 21.634942-48.717801 48.44682 0 12.366002 4.700699 23.655161 12.36398 32.185983 26.879623 54.161673 41.996884 115.107963 41.996884 179.615419 0 223.223017-180.958187 404.115481-404.047736 404.115481-223.088538 0-403.975946-180.82573-403.975946-404.115481 0-223.088538 180.887408-403.981002 403.975946-403.981002 87.219241 0 167.922823 27.61673 233.907526 74.587315 9.073794 12.099066 23.653138 19.89076 39.915998 19.89076 27.549996 0 49.855311-22.378116 49.855311-49.788577 0-14.046484-5.91101-26.612688-15.11726-35.681426L820.034933 126.58519c-0.265925-0.204246-0.671384-0.471182-0.805863-0.670373-2.081897-1.954496-4.300295-3.629922-6.853374-5.244681C727.84199 55.423551 621.674354 16.517662 506.499657 16.517662c-277.045965 0-501.546027 224.566796-501.546027 501.612761 0 276.980242 224.565785 501.546027 501.546027 501.546027s501.546027-224.565785 501.546027-501.546027C1008.180163 437.899034 989.298501 361.968951 955.837496 294.708215L955.837496 294.708215zM955.837496 294.708215"
              p-id="2176"
              fill="#1ccb89"
            ></path>
          </svg>
          <div style="float: left; margin-left: 8px">
            <p>授信总额度</p>
            {{ totalMoney }}
          </div>
        </el-card>
      </div>
      <div style="float: right; margin-right: 30px; margin-top: -20px">
        <el-card class="box-card" body-style="padding:10px">
          <svg
            t="1655111203869"
            class="icon"
            viewBox="0 0 1024 1024"
            version="1.1"
            xmlns="http://www.w3.org/2000/svg"
            p-id="2175"
            width="48"
            height="48"
            style="float: left; position: relative; top: 20px"
          >
            <path
              d="M512.483467 824.946804c27.883666 0 50.394238-22.577306 50.394238-50.399294l0-100.655009 101.466938 0c28.087912 0 50.665218-22.577306 50.665218-50.532762 0-27.816932-22.577306-50.527706-50.665218-50.527706L562.877705 572.832034l0-50.532762 101.466938 0c28.087912 0 50.665218-22.510572 50.665218-50.466028 0-27.883666-22.577306-50.460972-50.665218-50.460972l-76.269819 0 69.681359-69.819882c19.691569-19.686513 19.691569-51.671283 0-71.495309-19.686513-19.686513-51.738017-19.686513-71.429586 0.07179l-66.855277 66.922011-66.928078-66.922011c-19.686513-19.758303-51.671283-19.758303-71.429586-0.07179-19.753247 19.824026-19.753247 51.808796 0 71.495309l69.748093 69.819882-89.572118 0c-27.817943 0-50.527706 22.577306-50.527706 50.460972 0 27.955455 22.709763 50.466028 50.527706 50.466028l100.59333 0 0 50.532762-100.59333 0c-27.817943 0-50.527706 22.711785-50.527706 50.527706 0 27.955455 22.709763 50.532762 50.527706 50.532762l100.59333 0 0 100.655009C461.950706 802.369497 484.594746 824.946804 512.483467 824.946804L512.483467 824.946804zM512.483467 824.946804M955.837496 294.708215c-1.814961-4.97269-4.101104-9.540932-7.054587-13.642036-0.404448-0.670373-0.809907-1.409502-1.075832-2.081897l-0.537916 0.201213c-8.802814-10.883699-22.305315-17.805829-37.29113-17.805829-26.879623 0-48.717801 21.634942-48.717801 48.44682 0 12.366002 4.700699 23.655161 12.36398 32.185983 26.879623 54.161673 41.996884 115.107963 41.996884 179.615419 0 223.223017-180.958187 404.115481-404.047736 404.115481-223.088538 0-403.975946-180.82573-403.975946-404.115481 0-223.088538 180.887408-403.981002 403.975946-403.981002 87.219241 0 167.922823 27.61673 233.907526 74.587315 9.073794 12.099066 23.653138 19.89076 39.915998 19.89076 27.549996 0 49.855311-22.378116 49.855311-49.788577 0-14.046484-5.91101-26.612688-15.11726-35.681426L820.034933 126.58519c-0.265925-0.204246-0.671384-0.471182-0.805863-0.670373-2.081897-1.954496-4.300295-3.629922-6.853374-5.244681C727.84199 55.423551 621.674354 16.517662 506.499657 16.517662c-277.045965 0-501.546027 224.566796-501.546027 501.612761 0 276.980242 224.565785 501.546027 501.546027 501.546027s501.546027-224.565785 501.546027-501.546027C1008.180163 437.899034 989.298501 361.968951 955.837496 294.708215L955.837496 294.708215zM955.837496 294.708215"
              p-id="2176"
              fill="#1ccb89"
            ></path>
          </svg>
          <div style="float: left; margin-left: 8px">
            <p>总可用额度</p>
            {{ totalAvailable }}
          </div>
        </el-card>
      </div>
    </el-form>
    <!--列表-->
    <el-table
      size="small"
      :data="listData"
      highlight-current-row
      v-loading="loading"
      border
      element-loading-text="拼命加载中"
      style="width: 100%"
    >
      <el-table-column align="center" type="selection" width="60">
      </el-table-column>
      <el-table-column prop="id" label="额度编号" width="120">
      </el-table-column>
      <el-table-column prop="bname" label="授信机构" width="160">
      </el-table-column>
      <el-table-column sortable prop="total" label="授信额度" width="160">
      </el-table-column>
      <el-table-column sortable prop="available" label="可用额度" width="160">
      </el-table-column>
      <el-table-column
        sortable
        prop="start_time"
        label="额度起始日"
        width="160"
      >
      </el-table-column>
      <el-table-column sortable prop="end_time" label="额度到期日" width="160">
      </el-table-column>
      <el-table-column sortable prop="status" label="状态" mini-width="100">
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <Pagination
      v-bind:child-msg="pageparm"
      @callFather="callFather"
    ></Pagination>
    <!-- 编辑界面 -->
  </div>
</template>

<script>
import switchOne from '../../components/switchOne.vue'
import Pagination from '../../components/Pagination'
export default {
  data() {
    return {
      statusOptions: [
        {
          value: "正常",
          label: "正常"
        },
        {
          value: "过期",
          label: "过期"
        },
      ],
      editFormVisible: false,
      defaultProps: {
        children: 'enterprises',
        label: 'ename'
      },
      supplyList: [],
      bankOption: [],
      createNetworkDialog: false,
      nshow: true, //switch开启
      fshow: false, //switch关闭
      loading: false, //是显示加载
      editFormVisible: false, //控制编辑页面显示与隐藏
      title: '添加',
      editForm: {
        eid: "",
        ename: "",
        username: "",
        address: "",
        phonenum: "",
        enterprises: [],

      },
      formInline: {
        currentPage: 1,
        pageSize: 10,
        eid: "",
        id: "",
        bname: "",
        status: ""
      },
      // 删除部门
      seletedata: {
        ids: '',
        token: localStorage.getItem('logintoken')
      },
      userparm: [], //搜索权限
      listData: [], //用户数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10
      },
      //登录企业id
      id: "",
      totalMoney: "",
      totalAvailable: "",
    }
  },
  // 注册组件
  components: {
    Pagination,
    switchOne
  },

  /**
   * 创建完毕
   */
  created() {
    this.id = JSON.parse(localStorage.getItem("userdata")).enterprise_id;
    this.formInline.eid = JSON.parse(localStorage.getItem("userdata")).enterprise_id;
    this.getdata(this.formInline)
  },

  /**
   * 里面的方法只有被调用才会执行
   */
  methods: {
    //拒绝邀请
    refuse(row) {
      this.$confirm('确定要拒绝吗?', '信息', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$axios.delete('/api/supply/refuse/' + row.eid + '/' + this.id)
            .then(res => {
              console.log();
              if (res.data.code == 200) {
                this.getdata()
                this.$message({
                  type: 'info',
                  message: res.data.message
                })
              }
            })
            .catch(err => {
              this.$message.error('拒绝失败，请稍后再试！')
            })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    handleSelectionChange(val) {
      this.submitData.enterprises = val;
      console.log(this.submitData.enterprises)
    },
    getCheckedKeys2() {
      console.log(this.$refs.tree.getCheckedKeys());
      this.editForm.eids = this.$refs.tree.getCheckedKeys()
    },
    getdata() {
      this.loading = true
      //查询所有邀请
      this.$axios.post('/api/bank/allAmount/', this.formInline)
        .then(res => {
          console.log(res);
          this.loading = false
          if (res.data.code == 200) {
            this.$message({
              type: 'info',
              message: res.data.message
            })
            this.listData = res.data.data.list
            // 分页赋值
            this.pageparm.currentPage = this.formInline.currentPage
            this.pageparm.pageSize = this.formInline.pageSize
            this.pageparm.total = res.data.data.total
          }
        })
        .catch(err => {
          this.loading = false
          this.$message.error('授信额度加载失败，请稍后再试！')
        }),
        this.$axios.post('/api/bank/findTotal/', this.formInline)
          .then(res => {
            console.log(res);
            this.loading = false
            if (res.data.code == 200) {
              this.$message({
                type: 'info',
                message: res.data.message
              })
              this.totalMoney = res.data.data.totalMoney
              this.totalAvailable = res.data.data.totalAvailable
            }
          })
          .catch(err => {
            this.loading = false
            this.$message.error('授信额度加载失败，请稍后再试！')
          })
    },
    // 分页插件事件
    callFather(parm) {
      this.formInline.currentPage = parm.currentPage
      this.formInline.pageSize = parm.pageSize
      this.getdata(this.formInline)
    },
    // 搜索事件
    search() {
      this.loading = true
      this.$axios.post('/api/bank/findBy', this.formInline)
        .then(res => {
          console.log(res);
          this.loading = false
          if (res.data.code == 200) {
            this.$message({
              type: 'info',
              message: res.data.message
            })
            this.listData = res.data.data.list
            // 分页赋值
            this.pageparm.currentPage = this.formInline.currentPage
            this.pageparm.pageSize = this.formInline.pageSize
            this.pageparm.total = res.data.data.total

          } else {
            this.listData = []
            this.$message({
              type: 'info',
              message: res.data.message
            })
          }
          this.formInline.bname = ""
          this.formInline.id = ""
          this.formInline.status = ""

        })
        .catch(err => {
          this.loading = false
          this.$message.error('供应链查询失败，请稍后再试！')
        })
    }

  }
}
</script>

<style scoped>
.el-row {
  margin-bottom: 20px;
  /* &:last-child {
    margin-bottom: 0;
  } */
}
.user-search {
  margin-top: 20px;
}
.userRole {
  width: 100%;
}
.create-course-dialog .el-dialog {
  margin-top: 40px !important;
  width: 1000px;
  height: 820px;
  position: relative;
}
.create-course-dialog .el-upload {
  width: 100px;
  position: relative;
  left: 5px;
  top: 5px;
}
.create-course-dialog img {
  width: 100%;
  height: 100%;
}
.create-course-dialog .el-dialog__title {
  font-size: 30px;
}
.create-course-dialog .el-form-item__label {
  font-size: 18px;
  width: 90px;
}
.create-course-dialog .el-form-item {
  margin-top: 10px;
}
.create-course-dialog .el-input {
  width: 250px;
}
.create-course-dialog .dialog-left {
  float: left;
  border: 1px #bababa solid;
  border-radius: 5px;
  width: 420px;
  height: 380px;
  position: relative;
}
.create-course-dialog .dialog-right {
  float: right;
  border: 1px #bababa solid;
  border-radius: 5px;
  width: 500px;
  height: 380px;
}
.create-course-dialog .dialog-footer {
  position: absolute;
  bottom: 20px;
  right: 30px;
}
.create-course-dialog .el-input-number .el-input {
  width: 100%;
}
.create-course-dialog .el-input-number {
  width: 100px;
}
.create-course-dialog .el-form-item__error {
  margin-left: 90px;
}
.el-popover {
  max-width: 860px;
  max-height: 760px;
  overflow: auto;
}
.small-img img {
  height: 100px;
}
.small-img {
  padding: 5px;
  float: left;
}
</style>


